import 'package:enterprise_v6_app/app/core/http/http.dart';
import 'package:enterprise_v6_app/app/core/utils/interface.dart';
import 'package:enterprise_v6_app/app/data/entities/closure/closure_appointment_entity.dart';
import 'package:enterprise_v6_app/router/app_pages.dart';
import 'package:get/get.dart';

class AppointmentReviewController extends GetxController {

  // 跳转详情 0: 人员 1: 普通车辆 2: 危化车辆
  void toDetails(int i,ClosureAppointmentEntity item) {
    Get.toNamed(AppRoutes.appointmentReviewDetails,arguments: {
      'type': i,
      'item': item,
    });
  }

  // 预约审核列表(所有任务) [type] 0: 人员 1: 普通车辆 2: 危化车辆
  Future<List<ClosureAppointmentEntity>> checkAssetsDetails(int pageNum,int pageSize, int type, {String? search}) async {
    List<ClosureAppointmentEntity> list = [];
    final res = await HttpUtil().generateGetRequest<List<ClosureAppointmentEntity>>(Interface.getAuditListAll,queryParameters: {
      'pageNum': pageNum,
      'pageSize': pageSize,
      'reservationType': type,// 1: 人员 2: 车辆
      'licensePlate': type != 0 ? search : null,// 车牌号
      'name': type == 0 ? search : null , // 人员姓名
    }).execute();

    res.onSuccess((result) {
      if(result.data != null) {
        list = result.data!;
      }
    });
    return list;

  }

}
